﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using Ewts.Code;
using DataLib.Common;
using System.Data;
using DataLib.Accounts.Bus;

namespace Ewts.RDLC
{
    public partial class TallySelectRDLC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Session["UserInfo"] != null)
                {
                    User curUser = new DataLib.Accounts.Bus.User();
                    curUser = (User)Session["UserInfo"];
                    if (curUser.UserType == "CA" || curUser.UserType == "CB")
                    {
                        btnSearch.Enabled = false;
                    }
                }
                if (Request["loadnum"] != null && Request["loadnum"].ToString() != "")
                {
                    txtLoadnum.Text = Request["loadnum"];
                    Search();
 
                }
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Search(); 
        }

        public void Search()
        {
            TallySltReportView.Visible = true;
            string loadnum = this.txtLoadnum.Text;
            string cum = this.txtcum.Text;
            string dtime1 = this.txtTime1.Text;
            string dtime2 = this.txtTime2.Text;
            string b_goodscode = this.txtAgoCollectCode.Text;
            string b_boxid = this.txtAgoCollectLdh.Text;
            string b_ldh = this.txtDoGoodsNo.Text;
            string classtype = this.txtClassify.Text;
            string a_goodscode = this.txtGoodsCode.Text;
            string a_boxid = this.txtBarCode.Text;
            string a_ldh = this.txtBOXID.Text;
            DataTable dt = new DataTable();
            dt = new DataLib.BLL.Tally().GetTallyItem(loadnum, cum, dtime1, dtime2, b_goodscode, b_boxid, b_ldh, classtype, a_goodscode, a_boxid, a_ldh);
            ReportDataSource rds = new ReportDataSource("TallyStorageSltDS", dt);
            TallySltReportView.LocalReport.DataSources.Clear();
            TallySltReportView.LocalReport.DataSources.Add(rds);
            new RDLCPrinter().FillRow(dt, 3, 30, 30);
            TallySltReportView.LocalReport.Refresh();
            
        }
    }
}